package game.game.ia.transition;

import entity.GameEntity;
import entity.object.EnemyEntity;
import game.engine.ia.ICleverEntity;
import game.engine.ia.IState;
import game.game.GameModel;
import game.game.ia.IGameIAModel;

import java.util.List;

public class TransitionDetectUnfriend extends GameIATransition
{

	public TransitionDetectUnfriend(IGameIAModel pModel, IState pNextState)
	{
		super( pModel, pNextState );
	}

	@Override
	public boolean isValidTransition( ICleverEntity pEntity )
	{
		// TODO Auto-generated method stub
		GameModel model = (GameModel) _model;
		EnemyEntity entity = (EnemyEntity) pEntity;
		Integer vision = entity.getVision();
		//
		List<GameEntity> objInVision = new VisionManager().getObjEntityInVision( model , entity , vision );
		if ( !objInVision.isEmpty() )
		{
			entity.setTarget( objInVision.get( 0 ) );
		}
		return !objInVision.isEmpty();
	}
}
